# Contributor: David Demelier <markand@malikania.fr>
# Maintainer: David Demelier <markand@malikania.fr>
pkgname=libretro-flycast
pkgver=0_git20220406
pkgrel=1
_commit="4c293f306bc16a265c2d768af5d0cea138426054"
pkgdesc="libretro core for flycast"
url="https://github.com/libretro/flycast"
arch="x86_64 aarch64"
license="GPL-2.0-only"
makedepends="libzip-dev mesa-dev miniupnpc-dev zlib-dev"
source="$pkgname-$_commit.tar.gz::https://github.com/libretro/flycast/archive/$_commit.tar.gz
	patch-unbundle.patch
	miniupnpc.patch
	"
builddir="$srcdir/flycast-$_commit"
options="!check" # No tests

case $CARCH in
aarch64)
	_args="WITH_DYNAREC=arm64 HOST_CPU_FLAGS=-DTARGET_LINUX_ARMv8" ;;
arm*)
	_args="WITH_DYNAREC=arm" ;;
esac

if [ "$CARCH" != "x86" ]; then
	_args="$_args HAVE_GENERIC_JIT=0 HAVE_VULKAN=0"
fi

build() {
	rm -rf core/deps/libzip
	rm -rf core/deps/miniupnpc
	rm -rf core/deps/zlib
	make $_args \
		HAVE_LTCG=0 \
		SYSTEM_LIBZIP=1 \
		SYSTEM_ZLIB=1
}

package() {
	install -Dm644 flycast_libretro.so "$pkgdir"/usr/lib/libretro/flycast_libretro.so
}

sha512sums="
ea8b1971f88293f8a1655cfe1a1c94b1dc8e915908bd8ec6c599125005ac9ad38ff7accfeadc255159149ed3a306861a924e840037a1d2bd383ad4bdcfd83f39  libretro-flycast-4c293f306bc16a265c2d768af5d0cea138426054.tar.gz
98edf29148cf990de8ce1c1a15548e122ce30944645d9b92715fe3c86e021439fdeea1dabacbcbff46de211b5c2875bfc330d5a602f59498bbe745708a3d1e15  patch-unbundle.patch
e7f7f7a9bfc3ecce25b01007aba2119539be1912129be74f1271035a398f55b43404860f874d58fbacf81689fd0fc9a9ba012ad355011ed796d53f9e880e348f  miniupnpc.patch
"
